<template>
  <!-- 小区总水量分析  日表 -->
  <div class="FlCommunityDayWaterAnalysis">
    <!-- 左边树 -->
    <!-- 树形图 -->
    <!-- 右边list -->
    <!-- <button class="leftTreetitleButton" @click="treeShowOrClose = true" v-if="!treeShowOrClose">
         <i class="el-icon-caret-right"></i>
    </button>
    <div class="leftTree" v-if="treeShowOrClose">

      <waterMeterLeftTree class="waterMeterLeftTree" @clickClose="clickClose" @areaIf="areaIf" />
    </div>

    <div :class="[
            { rightcontant: treeShowOrClose },
            { rightcontant2: !treeShowOrClose },
        ]"> -->
    <!-- 搜索框  cz_btnDay ? [...searchData,...searchDataCzTime,...searchDataEnd] : [...searchData,...searchDataOtherTime,...searchDataEnd] -->
    <div style="padding: 0px 0px;">
      <searchComponentsCss v-if="cz_btnDay" :searchData="searchData" :optionsZi="optionsZi" :searchOptionTable="searchOptionTable" :shrinkBoxOpenClose='shrinkBoxOpenClose' @searchCallBack="searchCallBack"></searchComponentsCss>
      <searchComponentsCss v-else :searchData="searchDataOtherTime" :optionsZi="optionsZi" :searchOptionTable="searchOptionTable" :shrinkBoxOpenClose='shrinkBoxOpenClose' @searchCallBack="searchCallBack"></searchComponentsCss>
      <!-- 收缩框 -->
      <div class="shrinkBox" @click="shrinkBoxOpenClose = !shrinkBoxOpenClose">
        <i :class="shrinkBoxOpenClose?'el-icon-arrow-up':'el-icon-arrow-down'" v-if="numSearch>8"></i>
      </div>
      <!-- @clearSearch='clearSearch' -->
      <div style="border-top:1px solid #E6E6E6;margin:0px 30px 0 0;"></div>
      <div class="right_rows">
        <!--新增按钮-->

        <derivedTbale v-if="but_derivedTbale" class="importX" :suoS='suoS' :disabled='disabled' :multipleSelection='multipleSelection' />

        <rightButtons class="right_buttons" @sunS_F='sunS_F' @emptySearch='emptySearch' @configuration='configuration' @goFatherComponent="goFatherComponent" :configurationData="searchData" :btn-switch-configuration="false"></rightButtons>
      </div>
    </div>
    <!-- 表格 -->
    <div class="out">

      <!-- <dictionaries :searchData="searchData" :modelType="modelType" @optionData="dictionariesCallBack"></dictionaries> -->

      <!--数据列表-->
      <!-- 字典 -->
      <!-- [...searchData,...searchDataEnd] -->
      <dictionariesPlus :searchData='searchData' :modelType='modelType' @optionData="dictionariesCallBack"></dictionariesPlus>

      <el-table v-show="false" max-height='520px' ref="multipleTable" :data="dataAttribute" v-loading.body="loading" row-key="id" border fit highlight-current-row size="mini" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" :cell-style="{padding:'5px 0'}" @sort-change="sortChangeTable" @selection-change="handleSelectionChange" @row-click='rowClickType'>
        <el-table-column align="center" type="selection" :show-overflow-tooltip="true" width="55"></el-table-column>
        <el-table-column align="center" label="序号" :show-overflow-tooltip="true" type="index" :index="indexMethod" width="50">
        </el-table-column>
        <!-- el-icon-folder   el-icon-folder-opened -->
        <el-table-column min-width="50" :prop="item.EN" align="center" v-for="item in searchData" v-if="item.tableSign" :key="item.id" :label="item.CN" :sortable="customMethod" :show-overflow-tooltip="true">
          <template slot-scope="scope">{{item.type === 'select' ? optionDatas(item.typeGroupCode?optionsZi[item.EN]:searchOptionTable[item.EN],scope.row[item.EN]):scope.row[item.EN]}}</template>
        </el-table-column>
        <el-table-column align="center" label="操作">
          <template slot-scope="scope">

          </template>
        </el-table-column>
      </el-table>

      <!-- OLD -->
      <el-table ref="multipleTable" :data="dataAttribute" v-loading.body="false" border fit highlight-current-row size="mini" show-summary :summary-method='getSummaries' :cell-style="{padding:'5px 0'}" @selection-change="handleSelectionChange" @sort-change="sortChangeTable" max-height="520px">
        <el-table-column align="center" type="selection" :show-overflow-tooltip="true" width="45"></el-table-column>
        <el-table-column align="center" label="序号" type="index" :index="indexMethod" width="54px">
        </el-table-column><!-- communityName -->
        <el-table-column align="center" v-for="item in searchData" v-if="item.tableSign" :key="item.id" :label="item.CN" :prop="item.EN" :sortable="customMethod" :show-overflow-tooltip="true" min-width="140px">
          <template slot-scope="scope">{{item.type === 'select' ? optionDatas(item.typeGroupCode?optionsZi[item.EN]:searchOptionTable[item.EN],scope.row['communityCode']):scope.row[item.EN]}}</template>
        </el-table-column>

      </el-table>

      <el-pagination class="pagination" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="pagetotal"></el-pagination>
    </div>
    <!-- </div> -->
    <!-- 查看组件 -->
    <examine :DialogVisibleMod="DialogVisibleExamine" :modData="examineData" :optionsZi="optionsZi" :searchOptionTable="searchOptionTable" :attributeOrder="searchData" @examineDialog="examineDialog"></examine>
  </div>
</template>
<script>
//引入组件
import {
  SearchCForL,
  searchComponents,
  searchComponentsCss,
  examine,
  rightButtons,
  dictionaries,
  dictionariesPlus,
  waterMeterLeftTree,
  // importXlsx
} from '@/views/components/FLPage'
//引入组件
import {
  buttonhurdle,
  importXlsx,
  batches,
  derivedTbale,
  importTbale,
  modificationi,
  downloadTemplate,
} from '@/views/components/revenueFLpage'
import {
  SAVE_CHECK_BOXS,
  GAIN_CHECK_BOXS,
} from '@/views/components/FLPage/fun/checkBoxFun'
import {
  addFlCommunityDayWaterAnalysis, //增加
  deleteFlCommunityDayWaterAnalysis, //删除
  searchFlCommunityDayWaterAnalysis, //分页查询
  modifyFlCommunityDayWaterAnalysis, //修改
  getFlCommunityDayWaterAnalysis, //根据ID获取
  exprotXls, //导出xlsx数据
  downTem, //导出下载模板
  addFlCommunityDayWaterAnalysisTree, // 日报表更改
} from '@/api/waterAnalysis/flCommunityDayWaterAnalysis/index'
import { getFullTime, getNowTime } from '@/utils'
import { add } from '@/utils/math'
export default {
  components: {
    waterMeterLeftTree,
    buttonhurdle,
    modificationi,
    examine,
    searchComponents,
    searchComponentsCss,
    importXlsx,
    rightButtons,
    dictionaries,
    dictionariesPlus,
    batches,
    derivedTbale,
    importTbale,
    downloadTemplate,
  },
  name: 'FlCommunityDayWaterAnalysis',
  data() {
    return {
      loading: false,
      but_add: true,
      but_delBatches: true,
      but_look: true,
      but_edit: true,
      but_del: true,
      but_derivedTbale: true,
      but_importTbale: true,
      but_downloadTemplate: true,
      loading: false,
      // lookOver:true,
      // editField:true,
      // Deletebu:true,
      disabled: true,
      numSearch: 0,
      //   收缩框开关
      shrinkBoxOpenClose: false,
      importUrl: 'api/cb/flCommunityDayWaterAnalysis/importXls',
      //搜索框
      suoS: {},

      //   搜索组件的数据 columnSize
      searchData: [
        {
          EN: 'communityCode',
          CN: '小区编号',
          value: '',
          type: 'select',
          option: [],
          err: '长度为2-20位的所有字符!',
          Exp: '^.{2,20}$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
          dictTable: {
            associated: '',
            id: 'id',
            name: 'code',
            table: 'fl_community',
          },
        },
        {
          EN: 'communityName',
          CN: '小区名称',
          value: '',
          type: 'input',
          option: [],
          err: '长度为2-20位的所有字符!',
          Exp: '^.{2,20}$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
        },

        {
          EN: 'rgWaterNum',
          CN: '日供水量',
          value: '',
          type: 'input',
          option: [],
          err: '长度为1-10位的小数，保留2位小数!',
          Exp: '^([1-9][0-9]*)+(.[0-9]{1,2})?$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
        },
        {
          EN: 'rsWaterNum',
          CN: '用水量',
          value: '',
          type: 'input',
          option: [],
          err: '长度为1-10位的小数，保留2位小数!',
          Exp: '^([1-9][0-9]*)+(.[0-9]{1,2})?$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
        },
        {
          EN: 'lsl',
          CN: '漏失率',
          value: '',
          type: 'input',
          option: [],
          err: '长度为1-10位的小数，保留2位小数!',
          Exp: '^([1-9][0-9]*)+(.[0-9]{1,2})?$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
        },
        {
          EN: 'createDate',
          CN: '统计日期起',
          value: getFullTime(),
          defaultFullTime: getFullTime(),
          type: 'date',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: false,
          tableSign: true,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },
        {
          EN: 'createDate1',
          CN: '统计日期止',
          value: getNowTime(),
          defaultFullTime: getNowTime(),
          type: 'date',
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: true,
          tableSign: false,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },
        {
          EN: 'lsStatus',
          CN: '漏损状态',
          value: '',
          type: 'select',
          option: [],
          err: '长度为1-10位的小数，保留2位小数!',
          Exp: '^([1-9][0-9]*)+(.[0-9]{1,2})?$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: false,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
          typeGroupCode: 'ls_status',
        },
        {
          EN: 'cjs',
          CN: '抄见数',
          value: '',
          type: 'input',
          option: [],
          err: '长度为1-10位的数字!',
          Exp: '^[0-9]+(\\.[0-9]{1,10})?$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
        },
        {
          EN: 'cjl',
          CN: '抄见率',
          value: '',
          type: 'input',
          option: [],
          err: '长度为2-20位的所有字符!',
          Exp: '^.{2,20}$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
        },
        {
          EN: 'customerNum',
          CN: '用户数',
          value: '',
          type: 'input',
          option: [],
          err: '长度为1-10位的数字!',
          Exp: '^[0-9]+(\\.[0-9]{1,10})?$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
        },
        {
          EN: 'lastReadNum',
          CN: '上次用水',
          value: '',
          type: 'input',
          option: [],
          err: '长度为2-20位的所有字符!',
          Exp: '^.{2,20}$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: false,
          modificationSign: true,
          configurationSign: true,
        },
        {
          EN: 'differenceValue',
          CN: '用水量增减',
          value: '',
          type: 'input',
          option: [],
          err: '长度为2-20位的所有字符!',
          Exp: '^.{2,20}$',
          result: true,
          sign: true,
          searchSign: false,
          addSign: true,
          tableSign: true,
          examineSign: true,
          examineDisabled: true,
          modificationSign: true,
          configurationSign: true,
        },
      ],
      searchDataOtherTime: [
        {
          EN: 'createDate',
          CN: '统计日期',
          value: getNowTime(), // getBeforeDate(0)
          defaultFullTime: getNowTime(),
          type: 'date', // Date
          option: [],
          Exp: '^.{3,20}$',
          err: '长度为3-20的所有字符!',
          result: true,
          sign: true,
          searchSign: true,
          addSign: false,
          tableSign: true,
          examineSign: false,
          examineDisabled: false,
          modificationSign: false,
        },
      ],

      //添加弹窗的数据模型
      diaDataAdd: {
        yyqName: '',
        pqName: '',
        pqNum: '',
        BH: '',
      },
      //删除----Start--------------------------------------
      deleteDataList: [],
      //删除----End----------------------------------------

      //查看----Start--------------------------------------

      //查看的弹窗控制器
      DialogVisibleExamine: false,

      //查看的数据
      examineData: {},

      //查看----End----------------------------------------

      //表格数据
      //后端传来的数据
      dataAttribute: [],
      //表格选中1
      multipleSelection: [],
      treeShowOrClose: false,
      //分页
      currentPage: 1, //当前页
      pagesize: 10, //每页条数
      pagetotal: 0, //总条数,
      modelType: 'table',
      optionsZi: [],
      searchOptionTable: [],
      flag: '1',
      cz_btnDay: false,
    }
  },
  props: {
    areaCodeq: {
      type: String,
      default: '',
    },
    defaultTreeId: {
      type: String,
      default: '',
    },
  },
  watch: {
    areaCodeq(newValue) {
      if (newValue) {
        this.flag = '1'
      }
      console.log('小区监听')
      this.areaCodeq = newValue
      this.suoS.communityCode = newValue
      this.forData(this.currentPage, this.pagesize, this.suoS)
    },
    defaultTreeId(newValue) {
      this.defaultTreeId = newValue
    },
  },
  computed: {
    optionDatas() {
      return function (arr, val) {
        if (arr) {
          for (let i = 0; i < arr.length; i++) {
            if (arr[i].value == val) {
              //alert(arr[i].label, '---', val)
              return arr[i].label
            }
          }
        }
      }
    },
    customMethod() {
      return 'custom'
      /* return function (item) {

      } */
    },
  },
  async created() {
    // 按钮权限配置
    // this.but_add = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_add'];
    // this.but_delBatches = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_delBatches'];
    // this.but_look = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_look'];
    // this.but_edit = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_edit'];
    // this.but_del = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_del'];
    // this.but_derivedTbale = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_derivedTbale'];
    // this.but_importTbale = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_importTbale'];
    // this.but_downloadTemplate = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_downloadTemplate'];
    // ------------------
    // this.but_search = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_search'];
    // this.but_reset = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_reset'];
    // this.but_pz = this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_peizhi'];
    this.cz_btnDay =
      this.$store.state.user.elements['flCommunityDayWaterAnalysis:but_czDay']
    //获取保存的’配置‘
    //1.ajax
    this.getSSearchNum()
    let userId = this.$store.state.user.id
    let routerName = this.$route.path
    let peizhiData = await GAIN_CHECK_BOXS(userId, routerName)
    //2.判断数据库里面是否有 以前存过的配置信息
    // this.searchData = peizhiData && JSON.parse(peizhiData)
    /* if (this.areaCodeq) {

    } */
    this.cz_btnDay
      ? this.forData(this.currentPage, this.pagesize, {
          createDate: getFullTime(),
          createDate1: getNowTime(),
        })
      : this.forData(this.currentPage, this.pagesize, {
          createDate: getNowTime(),
        })
  },

  methods: {
    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 1) {
          sums[index] = '统计'
          return
        }
        if (index === 4) {
          const values = data.map((item) => Number(item[column.property]))
          if (!values.every((value) => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return add(prev, curr)
              } else {
                return prev
              }
            }, 0)
            sums[index] += 0
          } else {
          }
        }
      })

      return sums
    },
    // 当表格的某一行被点击的时候触发
    rowClickType(row) {
      console.log(row)
      this.WaterMeterDataCode = row.code
      this.rightContent = true
      console.log(this.WaterMeterDataCode)
      this.rightTitle = row.name
    },
    clickClose(res) {
      if (res === '点击隐藏') {
        this.treeShowOrClose = false
      }
    },
    // 获取当天时间
    getToDay() {
      var aDate = new Date()
      var month =
        aDate.getMonth() < 9
          ? '0' + (aDate.getMonth() + 1)
          : aDate.getMonth() + 1
      var date = aDate.getDate() <= 9 ? '0' + aDate.getDate() : aDate.getDate()
      console.log(date, 66222)
      var toDate = aDate.getFullYear() + '-' + month + '-' + date + ' '

      let last =
        aDate.getHours() < 9 ? '0' + aDate.getHours() : aDate.getHours() + ':'
      aDate.getMinutes() < 9
        ? '0' + aDate.getMinutes()
        : aDate.getMinutes() + ':' + aDate.getSeconds() < 9
        ? '0' + aDate.getSeconds()
        : aDate.getSeconds()

      var mmhh = '00:00:00'
      var mmHhArr = [toDate, mmhh]
      console.log(mmHhArr, last, 662223)
      var mmHhStr = toDate + mmhh
      // var mmHhStr = mmHhArr.join(' ')
      console.log(mmHhStr, toDate, 662223)
      this.endDatemoren = mmHhStr
      // this.endDatemoren = mmHhStr

      return mmHhStr
    },
    getBeforeDate(n) {
      var n = n
      var d = new Date()
      var year = d.getFullYear()
      var mon = d.getMonth() + 1
      var day = d.getDate()
      if (day <= n) {
        if (mon > 1) {
          mon = mon - 1
        } else {
          year = year - 1
          mon = 12
        }
      }
      d.setDate(d.getDate() - n)
      year = d.getFullYear()
      mon = d.getMonth() + 1
      day = d.getDate()
      let s =
        year +
        '-' +
        (mon < 10 ? '0' + mon : mon) +
        '-' +
        (day < 10 ? '0' + day : day)
      return s
    },

    // 搜索框
    getSSearchNum() {
      let searchData = this.searchData
      let num = 0
      for (let i = 0; i < searchData.length; i++) {
        const element = searchData[i]
        if (element.searchSign) {
          num += 1
        } else {
          num = num
        }
      }
      this.numSearch = num
    },
    // 排序
    sortChangeTable(obj) {
      // 上升
      let prop = obj.prop
      // 排序  需求  将驼峰形式的字段 改为 下划线形式的字段
      let abc = prop.replace(/([A-Z])/g, '_$1').toLowerCase()
      if (obj.order === 'ascending') {
        let suoS = this.suoS
        suoS.sortName = abc
        suoS.sortType = obj.order
        this.forData(this.currentPage, this.pagesize, suoS) //刷新列表
      } else if (obj.order === 'descending') {
        let suoS = this.suoS
        suoS.sortName = abc
        suoS.sortType = obj.order
        this.forData(this.currentPage, this.pagesize, suoS) //刷新列表
        // 下降
      } else {
        // 正常
        let suoS = this.suoS
        suoS.sortName = abc
        suoS.sortType = ''
        this.forData(this.currentPage, this.pagesize, suoS) //刷新列表
      }
    },
    handleSuccessImport(newValue) {
      if (newValue == '导入成功') {
        this.forData(this.currentPage, this.pagesize, this.suoS)
      }
    },
    //配置的子组件通知
    async goFatherComponent(OverData) {
      //1.修改父组件的视图***************
      this.searchData = JSON.parse(JSON.stringify(OverData))
      //2.保存’配置‘的更改
      let obj = {}
      //三个参数都是string类型***********
      obj['userId'] = this.$store.state.user.id //1
      obj['routerName'] = this.$route.path ///jiChuZiLiao/flBook
      obj['stringData'] = JSON.stringify(OverData) //相当于this.searchData转成了字符串格式    [{"EN":"id","CN":"主键","value":""...
      //封装好的发请求方法*****************
      let save_check_boxs = await SAVE_CHECK_BOXS(obj)
    },
    // 配置
    configuration(msg) {
      if (msg == '配置') {
        console.log(msg)
      }
    },
    // 重置
    emptySearch(msg) {
      if (msg == '重置') {
        this.suoS = {}
        this.areaCodeq = ''
        this.suoS = this.cz_btnDay
          ? { createDate: getFullTime(), createDate1: getNowTime() }
          : { createDate: getFullTime() }
        this.currentPage = 1
        this.forData(this.currentPage, this.pagesize, this.suoS)
      }
    },
    // 字典组件回调
    dictionariesCallBack([a = {}, b = {}]) {
      // 正常字典
      this.optionsZi = a
      // 跨表字典
      this.searchOptionTable = b
      console.log('====', a, b)
    },
    //搜索
    sunS_F(msg) {
      if (msg == '搜索') {
        if (!this.cz_btnDay) {
          /* if (!this.suoS.hasOwnProperty('createDate')) {
            this.$message({
              type: 'warning',
              message: '请选择日期',
            })
            return
          }
          this.suoS = !this.suoS.createDate
            ? { createDate: getFullTime() }
            : this.suoS */

          if (!this.suoS.createDate) this.suoS.createDate = getFullTime()
        } else {
          if (!this.suoS.createDate) this.suoS.createDate = getFullTime()
          if (!this.suoS.createDate1) this.suoS.createDate1 = getNowTime()
        }
        this.currentPage = 1
        this.forData(this.currentPage, this.pagesize, this.suoS, 2) //刷新列表
      }
    },
    //查询组件回调
    searchCallBack(newData) {
      let obj = {}
      for (let i = 0; i < newData.length; i++) {
        obj[newData[i].EN] = newData[i].value
      }

      // obj = JSON.stringify(obj) == '{}' ? { createDate: this.getToDay() } : obj

      this.suoS = obj
    },
    //渲染数据初始
    //
    forData(page, size, searchData) {
      // if (!searchData.createDate) searchData.createDate = this.getToDay()

      searchData.communityCode = this.areaCodeq || ''
      searchFlCommunityDayWaterAnalysis(page, size, searchData)
        .then(({ data = [] }) => {
          // this.dataAttribute = data
          this.pagetotal = data.total
          this.dataAttribute = data.list

          if (this.dataAttribute.length == 0) {
            this.disabled = true
          } else {
            this.disabled = false
          }
        })
        .catch()
    },
    //添加用户--新增表单组件传来的参数
    toAdd(addData) {
      let obj = {}
      for (let i = 0; i < addData.length; i++) {
        obj[addData[i].EN] = addData[i].value
      }
      addFlCommunityDayWaterAnalysis(obj)
        .then((response) => {
          // this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
          if (response.flag) {
            this.$message({
              message: response.message,
              type: 'success',
            })
          } else {
            this.$message({
              message: response.message,
              type: 'warning',
            })
          }
        })
        .catch(() => {
          this.$message.error('添加失败')
        })
    },
    //按钮栏传递了删除命令
    toDelete(orderstring) {
      this.$confirm('确认删除？')
        .then((_) => {
          let idArr = []
          for (let i = 0; i < this.deleteDataList.length; i++) {
            idArr.push(this.deleteDataList[i].id)
          }
          if (idArr.length == 0) {
            this.$message({
              message: '请选择要删除的数据',
              type: 'warning',
            })
            return
          }
          deleteFlCommunityDayWaterAnalysis(idArr)
            .then((response) => {
              this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
              this.$message({
                message: '删除成功',
                type: 'success',
              })
            })
            .catch((error) => {
              this.$message({
                message: '删除失败',
                type: 'warning',
              })
            })
        })
        .catch((_) => {})
    },
    //单项删除
    deleteList(id) {
      let arrId = [id]
      this.$confirm('确认删除？')
        .then((_) => {
          deleteFlCommunityDayWaterAnalysis(arrId).then((response) => {
            this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
            this.$message({
              message: '删除成功',
              type: 'success',
            })
          })
          done()
        })
        .catch((_) => {})
    },
    //查看
    makeExaId(id) {
      getFlCommunityDayWaterAnalysis(id)
        .then((response) => {
          let copyDialog = true
          this.DialogVisibleExamine = copyDialog
          // console.log(response);
          this.examineData = response.data
        })
        .catch((error) => {
          alert('获取失败')
        })
    },
    //查看关闭弹窗
    examineDialog(dialogVisibleMod) {
      this.DialogVisibleExamine = false
    },

    //修改
    modifyData(value, modData) {
      if (value) {
        let id = modData.id
        modifyFlCommunityDayWaterAnalysis(id, modData)
          .then((response) => {
            this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
            if (response.flag) {
              this.$message({
                message: response.message,
                type: 'success',
              })
            } else {
              this.$message({
                message: response.message,
                type: 'warning',
              })
            }
          })
          .catch((error) => {
            this.$message({
              message: '修改失败',
              type: 'warning',
            })
            this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
          })
      } else {
        this.forData(this.currentPage, this.pagesize, this.suoS) //刷新列表
      }
    },
    //表格选中事件
    handleSelectionChange(val) {
      this.multipleSelection = val
      this.disabled = val.length ? false : true
      //传递删除的参数
      this.deleteDataList = val
    },

    //分页
    handleSizeChange(val) {
      console.log('每页 ' + val + ' 条')

      this.pagesize = val
      this.forData(this.currentPage, val, this.suoS)
    },
    handleCurrentChange(val) {
      console.log('当前页: ' + val)
      this.currentPage = val

      this.forData(val, this.pagesize, this.suoS)
    },
    // 序号
    indexMethod(index) {
      var currentPage = this.currentPage
      var pagesize = this.pagesize
      this.$nextTick(function () {
        currentPage = this.currentPage
        pagesize = this.pagesize
      })
      return currentPage * pagesize - pagesize + 1 + index
    },
    // 下载模板请求
    exprotXlsx: exprotXls,
    downloadFile: downTem,
    //工具栏组件传来的参数
    // FTableFunction(attributeOrderCloneTwiceL) {
    //   this.attributeOrder = attributeOrderCloneTwiceL;
    // },
  },
}
</script>
<style scoped src="@/styles/allCssP.css"></style>
<style lang="scss" scoped>
.FlCommunityDayWaterAnalysis {
  .sout {
    padding: 25px 30px 0px 0px !important;
  }
  .out {
    padding: 0 30px 0 0 !important;
    /deep/.pagination {
      text-align: left !important;
      margin-top: 18px;
    }
  }
  .right_rows {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 20px 30px 20px 0 !important;
    .buttonhurdle {
      padding: 0px;
      padding-right: 15px;
    }
    .buttons {
      padding: 0px !important;
    }
    .right_buttons {
      padding: 0px !important;
    }
  }
}
.FlCommunityDayWaterAnalysis {
  //   display: flex;
  .shrinkBox {
    text-align: center;
    font-weight: 700;
    font-size: 20px;
    height: 25px;
  }
  .leftTreetitleButton {
    margin-top: 10px;
    border: 0;
    height: 32px;
  }
  .leftTree {
    width: 14.2%;
    .waterMeterLeftTree {
      border: 1px soild #ccc;
    }
  }
  .rightcontant {
    display: flex;
    flex-direction: column;
    width: 85.8%;
    /deep/.el-table--mini {
      .gutter {
        display: table-cell !important;
      }
      .el-checkbox__inner {
        width: 12px;
        height: 12px;
      }
      /deep/.el-table__body-wrapper {
        .el-table__body {
          tbody {
            .el-table__row {
              height: 45px !important;
            }
          }
        }
      }
      // 改变表头的高度  改为45px
      .el-table__header-wrapper {
        .el-table__header {
          .has-gutter {
            tr {
              th {
                /*  padding: 5px 0 !important;
                height: 34px;
                line-height: 34px; */
              }
            }
          }
        }
      }
      // 表头操作固定定位
      .el-table__fixed-right {
        .el-table__header {
          thead {
            tr {
              th {
                padding: 5px 0 !important;
                height: 34px;
                line-height: 34px;
              }
            }
          }
        }
      }
    }

    .do {
      display: flex;
    }
    .pagination {
      text-align: left !important;
      margin-top: 20px;
    }
  }
}
</style>
